﻿@model RegisterEditModel
@{
    ViewData["Title"] = new string[] { "关联手机号" };
    var errorMessage = TempData.Get<string>("codeError", string.Empty);
}
<style type="text/css">
    .btn-default[disabled]:hover {
        color: #333;
    }
</style>
<div class="jh-login-home">
    <h1 class="tn-mb-30 tn-space-xlg-hor">关联新帐号</h1>
    @using (Html.BeginForm("AssociatePhone", "Account", FormMethod.Post, new { @id = "RegisterForm", @class = "tn-space-xlg-hor form-horizontal tn-form-validation " }))
    {
        <div class="form-group">
            <label>手机注册</label>
            @Html.TextBoxFor(n => n.AccountMobile, new { @class = "form-control" })
            @Html.ValidationMessageFor(n => n.AccountMobile)
            <span class="help-block tn-mb-0">或使用<a href="@SiteUrls.Instance().AssociateEmail()" class="a tn-ml-5">邮箱注册</a></span>
        </div>
        <div class="form-group "  id="passwordLoad" >
            @Html.Action("_PassWordPoclaimed", "Account", new { passWordTitle = "密码" })
            <span style="top:25px" class="glyphicon  form-control-feedback" aria-hidden="true"><i class="fa fa-eye-slash"></i></span>
            <input class="tn-click-eye" type="button" />
            @Html.ValidationMessageFor(n => n.PassWord)
            <span class="help-block tn-mb-0">字母、数字至少6位</span>
        </div>
        <div class="form-group">
            <label>激活码</label>
            <div class="row">
                <div class="col-xs-6">
                    <input id="getCode" type="button" class="btn btn-default" value="免费获取短信激活码" />
                </div>
                <div class="col-xs-6">
                    @Html.TextBoxFor(n => n.VerfyCode, new { @class = "form-control" })
                    @Html.ValidationMessageFor(n => n.VerfyCode)
                    <span id="qtts" style="color:red;display:none">@errorMessage</span>
                </div>
            </div>
        </div>

        var mathBuildInfoModel = new ViewDataDictionary();

        mathBuildInfoModel.Add("InputText", "换一换");
        mathBuildInfoModel.Add("ErrorMessage", errorMessage);
        mathBuildInfoModel.Add("RequiredMessage", "请输入正确验证码");
        mathBuildInfoModel.Add("IsRequired", true);
        @Html.Captcha(4, "_DefaultCaptchaView", mathBuildInfoModel).AsIntelligent()
        <div class="form-group">
            <div class="checkbox">
                <label>
                    <input style="margin-top:6px" id="ispass" type="checkbox"><small> 我已看过并完全同意 <a href="javascript:;"   class="a tn-ml-5 layerprovision">《用户使用协议》</a> </small>
                </label>
            </div>
        </div>
        <div class="form-group">
            <button type="submit" class="btn btn-primary tn-btn-wm">关联新帐号</button>
        </div>
    }

</div>
<script>
   require(['jquery','tnlayer'],function($.tnlayer){
      
      $(".layerprovision").click(function(){
          tnlayer.layermodal('注册条款','@CachedUrlHelper.Action("_Provision","Account")','700px','500px')
      })
  

        $("#VerfyCode").blur(function() {
            if ($(this).val().length > 0) {
                $("#errormsg").hide();
            }

        });

        //其他错误提示
        $(function() {
            var type = typeof ($("#CaptchaDeTextmp").attr("type"));
            if (type == "string") {
                $("#qtts").show();
            }
        });

        $(".btn-primary").click(function() {
            $("#RegisterForm").validate();
            if ($("#RegisterForm").valid()) {
                if (!$("#ispass")[0].checked) {
                    layer.msg("请先阅读用户使用协议", {
                        icon: 2
                    });
                    return false;
                }
            }
        })
        $("#getCode").click(function() {
            var phone = $("#AccountMobile").val();
            var captchaInputText = $("#CaptchaInputText").val();
            var captchaDeText = $("#CaptchaDeText").val();
            $.post("@CachedUrlHelper.Action("SMSSend", "Account")", { phone: phone, type: 0 }, function(data) {
                if (data.state) {
                    layer.msg(data.msg, {
                        icon: 1
                    });
                    GetNumber();
                } else {
                    layer.msg(data.msg, {
                        icon: 2
                    });
                }
            })

        });

        //倒计时
        var count = 60;
        function GetNumber() {
            $("#getCode").attr("disabled", "disabled");
            $("#getCode").val(count + "秒之后再次获取")
            count--;
            if (count >= 0) {
                setTimeout(GetNumber, 1000);
            }
            else {
                $("#getCode").val("免费获取短信激活码");
                $("#getCode").removeAttr("disabled");
                count = 60;
            }
        };
     })
</script>